<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
    <link href="framework/reset.css" rel="stylesheet">
    <link rel="stylesheet" href="css/addUserAddress.css">
    <script src="js/pageJump.js"></script>
    <script src="https://fastly.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div class="wrapper" id="app">
        <!-- header部分 -->
        <header>
            <p>新增送货地址</p>
        </header>
        <!-- 表单部分 -->
        <ul class="form-box">
            <li>
                <div class="title">
                    联系人：
                </div>
                <div class="content">
                    <input type="text" v-model="address.name" placeholder="联系人
       姓名">
                </div>
            </li>
            <li>
                <div class="title">
                    性别：
                </div>
                <div class="content" style="font-size: 3vw;">
                    <input type="radio" name="sex" value="0" style="width:6vw;height:3.2vw;" v-model="address.sex">男
                    <input type="radio" name="sex" value="1" style="width:6vw;height:3.2vw;" v-model="address.sex">女
                </div>
            </li>
            <li>
                <div class="title">
                    电话：
                </div>
                <div class="content">
                    <input type="tel" v-model="address.phoneNumber" placeholder="电话">
                </div>
            </li>
            <li>
                <div class="title">
                    收货地址：
                </div>
                <div class="content">
                    <input type="text" v-model="address.address" placeholder="收货地址">
                </div>
            </li>
        </ul>
        <div class="button-add">
            <button @click="saveDeliveryAddress">保存</button>
        </div>
        
    </div>
    <script>
        var param=getRequest()
        var path=getRequestPath()
        var app=new Vue({
            el:"#app",
            data:{
                path:"https://localhost",
                address:{
                    name:'',
                    sex:0,
                    phoneNumber:null,
                    address:''
                }
            },
            methods:{
                saveDeliveryAddress:async function(){
                    axios.post(path+"/DeliveryAddressController/saveDeliveryAddress",null,{
                        params:{
                            contactName:this.address.name,
                            address:this.address.address,
                            contactTel:this.address.phoneNumber,
                            contactSex:this.address.sex
                        },
                        headers:{
                            Authorization:this.getAuthorization()
                        }
                    }).then((respon)=>{
                        if(respon.data.code==200){           
                            this.addressList=respon.data.detail
                            this.jumpTo("userAddress.html")
                        }
                    }).catch((error)=>{
                        console.log(error)
                    })
                },
                jumpTo:function(u){
                    window.location.href=u
                },
                getAuthorization:()=>{
                    console.log(window.localStorage.getItem("Auth"))
                    return window.localStorage.getItem("Auth")
                },
                removeUserAddress:function(daId){

                },
                
            },
            created() {
                
            }
        })
    </script>
</body>

</html>